class Solution(object):
    def removeDuplicates(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        i = 0
        now_value = nums[0]
        now_count = 0
        while i < len(nums):
            if nums[i] == now_value:
                now_count += 1
                if now_count > 2:
                    del nums[i]
                else:
                    i += 1
            else:
                now_value = nums[i]
                now_count = 1
                i += 1
        return len(nums)


data = Solution()
nums = [1, 1, 1, 2, 2, 3]
count = data.removeDuplicates(nums)
print(count, nums)
